//package com.lac.component.aop;
//
//import lombok.extern.slf4j.Slf4j;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.Signature;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.reflect.MethodSignature;
//import org.springframework.stereotype.Component;
//
//import java.lang.reflect.Method;
//
///**
// * @author xiaokuixiao
// * date2025/7/8 10:54
// */
//@Aspect
//@Component
//@Slf4j
//public class PermissionAspect {
//
//    @Around("@annotation(com.lac.component.aop.HasPermission)")
//    public Object around(ProceedingJoinPoint point) throws Throwable {
//        // 提取方法上的注解和权限标识
//        Signature signature = point.getSignature();
//        MethodSignature methodSignature = (MethodSignature) signature;
//        Method method = methodSignature.getMethod();
//        HasPermission annotation = method.getAnnotation(HasPermission.class);
//        String requiredPermission = annotation.value();
//        Boolean hasPermission =  true;
//        // 校验权限
//        if (hasPermission) {
//            return point.proceed();  // 放行方法执行
//        } else {
//            log.info("权限不足，缺少权限：{}", requiredPermission);
//            // 拒绝访问，返回错误信息
//            throw new InsufficientPermissionException(String.format("权限不足，缺少权限：%s", requiredPermission));
//
//        }
//    }
//
//}
